// 引入 request 文件
import request from '@/api/request'

// ==================== 用户认证登录 ====================
// 获取验证码
export const sendCaptcha = (data) => {
	return request({
		url: 'login/sendCaptcha',
		method: 'get',
		data: data,
		query: true
	})
}

// 手机号登录
export const login = (data) => {
	return request({
		url: 'login/telLogin',
		method: 'post',
		data: data,
		query: true
	})
}

// 微信登录
export const wxLogin = (data) => {
	return request({
		url: 'login/wxLogin',
		method: 'post',
		data: data,
		query: true
	})
}

// 用户注册
export const register = (data) => {
	return request({
		url: 'login/register',
		method: 'post',
		data: data
	})
}

// 注销账号
export const logOff = (data) => {
	return request({
		url: 'user/logOff',
		method: 'post',
		data: data
	})
}

// ==================== 用户信息管理 ====================
// 获取用户信息
export const getUserInfo = (data) => {
	return request({
		url: 'user/getById',
		method: 'post',
		data: data,
		query: true
	})
}

// 修改用户信息
export const updateUserInfo = (data) => {
	return request({
		url: 'user/update',
		method: 'post',
		data: data,
		updata: true
	})
}

// 上传文件
export const uploadFile = (data) => {
	return request({
		url: 'api/upload/uploadFile',
		method: 'post',
		data: data,
		updata: true
	})
}

// ==================== 地址管理 ====================
// 查看用户地址列表
export const getAddressList = (data) => {
	return request({
		url: 'address/list',
		method: 'get',
		data: data,
		query: true
	})
}

// 添加地址
export const addAddress = (data) => {
	return request({
		url: 'address/add',
		method: 'post',
		data: data
	})
}

// 修改地址
export const updateAddress = (data) => {
	return request({
		url: 'address/update',
		method: 'post',
		data: data
	})
}

// 删除地址
export const deleteAddress = (data) => {
	return request({
		url: 'address/delete',
		method: 'post',
		data: data,
		query: true
	})
}

// 设置默认地址
export const setDefaultAddress = (data) => {
	return request({
		url: 'address/setDefault',
		method: 'post',
		data: data,
		query: true
	})
}

// ==================== 会员管理 ====================
// 获取会员列表
export const getVipList = (data) => {
	return request({
		url: 'vip/list',
		method: 'get',
		data: data,
		query: true
	})
}

// 开通会员
export const openVip = (data) => {
	return request({
		url: 'vip/add',
		method: 'post',
		data: data
	})
}

// 用户会员信息
export const getUserVip = (data) => {
	return request({
		url: 'userVip/info',
		method: 'get',
		data: data,
		query: true
	})
}

// 购买会员
export const buyVip = (data) => {
	return request({
		url: 'userVip/add',
		method: 'post',
		data: data
	})
}

// ==================== 积分系统 ====================
// 获取积分记录
export const getPointRecord = (data) => {
	return request({
		url: 'pointRecord/list',
		method: 'get',
		data: data,
		query: true
	})
}

// 获取积分明细
export const getPointDetail = (data) => {
	return request({
		url: 'pointRecord/page',
		method: 'get',
		data: data,
		query: true
	})
}

// 积分兑换
export const exchangePoints = (data) => {
	return request({
		url: 'pointRecord/exchange',
		method: 'post',
		data: data
	})
}

// 获取积分商品列表
export const getPointProducts = (data) => {
	return request({
		url: 'pointProduct/list',
		method: 'get',
		data: data,
		query: true
	})
}

// ==================== 消息通知 ====================
// 获取通知列表
export const getNoticeList = (data) => {
	return request({
		url: 'notice/page',
		method: 'get',
		data: data,
		query: true
	})
}

// 获取通知详情
export const getNoticeDetail = (data) => {
	return request({
		url: 'notice/get',
		method: 'get',
		data: data,
		query: true
	})
}

// ==================== 价格变动记录 ====================
// 获取价格变动记录
export const getPriceRecord = (data) => {
	return request({
		url: 'priceRecord/page',
		method: 'get',
		data: data,
		query: true
	})
}

// ==================== 充值配置 ====================
// 获取充值配置列表
export const getRechargeConfigList = () => {
	return request({
		url: 'rechargeConfig/list',
		method: 'get'
	})
}

// 充值余额
export const rechargeAmount = (data) => {
	return request({
		url: 'recharge/rechargeAmount',
		method: 'post',
		data: data,
		query: true,
		updata:true
	})
}

// 开通会员
export const rechargeVip = (data) => {
	return request({
		url: 'recharge/rechargeVip',
		method: 'post',
		data: data,
		query: true,
		updata: true
	})
}

// ==================== 积分兑换 ====================
// 积分兑换商品
export const exchangeProduct = (data) => {
	return request({
		url: 'exchange/exchange',
		method: 'post',
		data: data
	})
}

// 查询用户兑换记录
export const getUserExchangeRecord = (data) => {
	return request({
		url: 'exchange/userQuery',
		method: 'get',
		data: data,
		query: true
	})
}

// ==================== 优惠券管理 ====================
// 查询用户优惠券列表
export const getUserCouponList = (data) => {
	return request({
		url: 'userCoupon/list',
		method: 'get',
		data: data,
		query: true
	})
}

// 领取优惠券
export const receiveCoupon = (data) => {
	return request({
		url: 'userCoupon/receive',
		method: 'post',
		data: data
	})
}
//获取积分
export const addAdReward = (data) => {
	return request({
		url: 'priceRecord/addAdReward',
		method: 'post',
		data: data
	})
}

// ==================== 我的页面相关 ====================
// 获取用户余额
export const getUserBalance = (data) => {
	return request({
		url: 'user/getBalance',
		method: 'get',
		data: data,
		query: true
	})
}

// 获取用户优惠券数量
export const getUserCouponCount = (data) => {
	return request({
		url: 'userCoupon/count',
		method: 'get',
		data: data,
		query: true
	})
}

// 提交反馈
export const submitFeedback = (data) => {
	return request({
		url: 'feedback/add',
		method: 'post',
		data: data
	})
}

// 获取系统配置
export const getSystemConfig = (data) => {
	return request({
		url: 'config/get',
		method: 'get',
		data: data,
		query: true
	})
}

// ==================== 个人中心相关接口 ====================
// 获取服务项目数量
export const getServiceCount = (data) => {
	return request({
		url: 'service/count',
		method: 'get',
		data: data,
		query: true
	})
}

// 获取积分数量
export const getPointsCount = (data) => {
	return request({
		url: 'user/getPoints',
		method: 'get',
		data: data,
		query: true
	})
}

// 获取订单状态统计
export const getOrderStatusCount = (data) => {
	return request({
		url: 'order/statusCount',
		method: 'get',
		data: data,
		query: true
	})
}
